<?php


if (isset($_GET['action']) && $_GET['action'] == "add")
	include('pages/add_shop.php');
elseif (isset($_GET['action']) && $_GET['action'] == "create_cmd")
	include('pages/create_commande.php');
elseif (isset($_GET['action']) && $_GET['action'] == "valid_cmd")
	include('pages/valid_commande.php');
elseif (isset($_GET['action']) and $_GET['action'] == "livraison")
	include ('pages/show_liv_mag.php');
elseif (isset($_GET['action']) AND $_GET['action'] == "check_liv")
	include ('pages/check_liv.php');
elseif (isset($_GET['action']) AND $_GET['action'] == "transfert")
	include ('pages/produit_transfert.php');
	elseif (isset($_GET['action']) AND $_GET['action'] == "import_ventes")
	include ('pages/import_ventes.php');
else
	{
?>
<div id="magasins">	
	<div id="mag_list">	
		
		<?php
		global $connect;
		$query = "SELECT * FROM magasins";
		$mag_list = mysql_query($query, $connect) or die(mysql_error());
		?>
			<tbody>
			<?php	
			if (isset($_GET['del_shop_id']))
				include ('pages/del_shop.php');
			else if(isset($_GET['edit_shop_id']))
				include ('pages/edit_shop.php');
			else if(isset($_GET['show_mag_id']))
				include ('pages/show_mag.php');
			else if(isset($_GET['action']) && $_GET['action'] == "localize")
				include ('pages/localize.php');
			else if(isset($_GET['approv_shop_id']))
				include ('pages/approv_shop.php');
			else
			{
			echo "<div class='box_info'>
			Cliquez sur  '<img src='img/lire.png' width='16px' height='16px'>' pour voir l'emplacement<br />
			Cliquez sur  '<img src='img/basket.png' width='16px' height='16px'>' pour modifier les infos du magasin  <br />
			Cliquez sur  '<img src='img/Delete.png' width='16px' height='16px'>' pour suppimer le magasin 
			</div><br />";
			?>
			<h1><center><a href="index.php?page=magasins&action=add"> <img src="img/list-add.png"  width="20px" height="20px"/> Ajouter un magasin </a></center></h1> <br /> <br />
			<h1>Liste des Magasins</h1>
			<table frame="border" border="1" cellspacing="0">
				<thead>
					<tr> <th>Nom</th> <th>Code</th> <th>Ville</th> <th>Adresse</th> <th>Code postal</th> <th>Telephone</th> <th>Actions</th></tr>
				</thead>
			<?php
				while ($data = mysql_fetch_array($mag_list))
				{
					echo "<tr > <td align='center' width='120px'><a href='index.php?page=magasins&show_mag_id=".$data['NMAGASIN']."'>".$data['NOM']."</a> </td>";
					echo "<td align='center' width='120px'>".$data['CODE']."</td>";
					echo "<td align='center' width='120px'>".$data['VILLE']."</td>";
					echo "<td align='center' width='120px'>".$data['ADRESSE']."</td>";
					echo "<td align='center' width='120px'>".$data['CP']."</td>";
					echo "<td align='center' width='120px'>".$data['TELEPHONE']."</td>";
					echo "<td align='center' width='120px'> <a href='index.php?page=magasins&action=localize&local=magasin&id=".$data['NMAGASIN']."'><img src='img/lire.png' alt='voir' width='20px' height='20px'/></a> 
					<a href='index.php?page=magasins&action=show_mag&edit_shop_id=".$data['NMAGASIN']."'><img src='img/basket.png' alt='modifier'width='20px' height='20px'/></a> 
					<a href='index.php?page=magasins&action=show_mag&del_shop_id=".$data['NMAGASIN']."'><img src='img/Delete.png' alt='supprimer' width='20px' height='20px'/></a></td></tr>";
				}
			}
			?>
			</tbody>
		</table>
	</div>
</div>
<?php
	}
	?>